import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { UserInfo } from '@/types'

export const useCounterStore = defineStore(
  'big-user', () => {
    const token = ref('')
    const setToken = (t: string) => {
      token.value = t
    }
    const getToken = () => {
      return token.value
    }
    const userInfo = ref<UserInfo | undefined>(undefined)
    const setUserInfo = (info?: UserInfo) => {
      userInfo.value = info
    }
    const logout = () => {
      userInfo.value = undefined
      token.value=''
    }


    return { token, setToken, getToken, setUserInfo, userInfo,logout }
  },
  {
    persist: true,
  },
)
